package org.zizi.dao;

import java.util.List;

import org.zizi.modal.UserInfo;

public class UserInfoDaoImpl extends BaseDao implements UserInfoDao
{
	public void addOrUpdateUserInfo(UserInfo info) throws Exception
	{
		UserInfo tmp = getUserInfo(info.getIdentify());
		if (tmp == null)
			esql.helper().inserti(info, "t_vat_user_info");
		else
			esql.helper().updatei(info, "t_vat_user_info", info.getId());
	}

	public UserInfo getUserInfo(String identify) throws Exception
	{
		return esql.helper().queryi(UserInfo.class, "t_vat_user_info", "identify=?", identify);
	}

	public List<UserInfo> searchManagingUserInfos(String identify, String orgRelationCode, int offset, int limit) throws Exception
	{
		return esql.page(UserInfo.class, offset, limit, "select ui.* from t_vat_user_info ui, t_inland_revenue_org org where ui.org_code=org.code and ui.identify like ? and org.relation_code like ? order by ui.identify", "%" + identify + "%", orgRelationCode + "%");
	}
}
